<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-bind指令</title>
    <style>
      .active {
        border: 1px solid red;
      }
    </style>
  </head>
  <body>
    <!-- v-bind对元素的属性进行操作 -->
    <div id="app">
      <img
        v-bind:src="dizhi"
        v-bind:title="title"
        v-bind:class="{active:isActive}"
      />
      <img v-on:click="toggleImg" :src="dizhi2" :class="{active:isActive2}" />
    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
      var app = new Vue({
        el: "#app",
        data: {
          dizhi: "./img/02.jpg",
          title: "马里奥",
          isActive: true,
          dizhi2: "./img/02.jpg",
          isActive2: false,
        },
        methods: {
          toggleImg: function () {
            (this.dizhi2 = "./img/01.jpg"), (this.isActive2 = !this.isActive2);
          },
        },
      });
    </script>
  </body>
</html>
